package com.rinlink.spock.demo.service

import com.rinlink.spock.demo.service.model.UpdateGoodsInDTO
import spock.lang.Specification

class GoodsServiceSpec extends Specification {
    def "更新商品价格"() {

        given: "商品服务"
        def goodsService = Mock(GoodsService)
        def goods = new UpdateGoodsInDTO(goodsPrice: price, goodsName: name)
        print goods.goodsName
        print goods.goodsPrice
        when: "更新商品价格"
        def result = goodsService.update(goodsId, goods)

        then: "返回结果"
        result == true
        1 * goodsService.update(_, _) >> {
            verifyAll(it) {
                it[0] == goodsId
                it[1].goodsPrice == price
                it[1].goodsName == name
            }
            return true
        }
        where: "商品信息"
        goodsId | price|name
        "1"       | 100|"苹果"

    }
}
